package com.huang.decorator;

import com.huang.decorator.entity.Clothes;
import com.huang.decorator.entity.Person;
import com.huang.decorator.service.impl.ClothesServiceImpl;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <p>装饰者
 * 在不改变原有对象的基础之上，将功能附加到对象上。提供了比继承更有弹性的替代方案（扩展原有对象功能）
 * </p>
 *
 * @author aneng huang
 * @since 2020-10-28 14:24:03
 */
public class DecoratorMain {
    private static final Logger logger = LoggerFactory.getLogger(DecoratorMain.class);

    @Test
    public void decoratorTest() {
        Person person = new Person("samuel");
        ClothesServiceImpl clothesService = new ClothesServiceImpl();
        Clothes clothes = new Clothes("帽子", "T-shirt", "破牛仔裤", "耐克鞋子");
        String showName = clothesService.show(clothes);

        logger.info(person.getUsername() + showName);
    }

    @Test
    public void decoratorV2Test() {
        Shape circle = new Circle();
        ShapeDecorator redCircle = new RedShapeDecorator(circle);
        redCircle.draw();
    }
}
